package com.link.base.base.securitypage.controller;


import com.link.base.base.securitypage.model.SecurityPage;
import com.link.base.base.securitypage.service.SecurityPageService;
import com.link.core.cllog.LCLogger;
import com.link.core.basic.annotations.JsonParam;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.ServiceException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * @author: unknown
 * @date: unknown
 * @Comments 安全性菜单
 */
@Controller
@RequestMapping("/link/securityPage")
public class SecurityPageController extends BasicController<SecurityPage> {

    @Resource
    private SecurityPageService securityPageService;

    @Override
    public BasicService<SecurityPage> getBasicService() throws Exception {
        return securityPageService;
    }

    /**
     * 根据条件查询记录,不分页
     */
    @RequestMapping(value = "/loadMenuPageUrlToRedis")
    @ResponseBody
    public Map<String, Object> loadMenuPageUrlToRedis(@JsonParam SecurityPage record, HttpSession session,
                                        HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> result = new HashMap<String, Object>();
        try {
            securityPageService.loadMenuPageUrlToRedis(record);
            result.put("success", true);
        } catch (Exception e) {
            LCLogger.withException(e);
            if (e instanceof ServiceException) {
                result.put("detailMessage", ((ServiceException) e).getMessage());
            }
            result.put("result", e.getMessage());
            result.put("success", false);
        }
        return result;
    }
}
